﻿using CubicFWNet.Application.SystemManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CubicFWNet.Common;
using CubicFWNet.Mvc.Models;
namespace CubicFWNet.Mvc.Controllers
{
    public class LogInLogController : ControllerBase
    {
        private LogApp _logApp;
        public LogInLogController()
        {
            _logApp = new LogApp();
        }
        [Authenticate]
        [HttpGet]
        public ViewResult Index(string timeType, string keyword = "", int page = 1, int rows = 20)
        {
            ViewBag.KeyWord = keyword;
            ViewBag.TimeType = timeType;
            return View(_logApp.Get(keyword, timeType, page, rows));
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public string SubmitRemoveLog(string keepTime)
        {
            try
            {
                _logApp.RemoveLog(keepTime);
            }
            catch (Exception ex)
            {
                Result.Status = "error";
                Result.Message = ex.Message;
            }
            return Result.ToJson();
        }
    }
}